package com.hopes.bizz.risk.control.vo;

import com.hopes.bizz.risk.common.constant.enums.RiskModDictEnum;
import com.hopes.bizz.risk.common.constant.enums.RiskSysDictEnum;
import com.hopes.bizz.risk.control.entity.RiskControlMeasureEntity;
import com.hopes.bizz.risk.control.entity.RiskUnitEventEntity;
import com.hopes.boss.admin.api.entity.SysDictItem;
import com.hopes.boss.admin.api.resolver.DictResolver;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.Optional;

/**
 * @author yumr
 * @time 2023/7/19 16:28
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "风险事件VO")
public class RiskUnitEventVO extends RiskUnitEventEntity {

    private static final long serialVersionUID = -4831938925902683982L;

    /* 合并行数 */
    private int rowCount;
    private int unitRowCount;

    /**
     * 风险对象
     */
    private Long riskObjectId;

    /* 风险单元 */
    private RiskUnitVO riskUnit;

    /* 风险管控措施数量 */
    private Integer riskControlMeasureNum;

    /* 风险管控措施 */
    private List<RiskControlMeasureVO> riskControlMeasureList;


    /* 风险对象 */
    public String getRiskObjectIdStr() {
        return DictResolver.getItemLabelByValue(RiskModDictEnum.risk_object, this.getRiskObjectId());
    }

    public String getAfterRiskLevelStr() {
        return DictResolver.getItemLabelByValue(RiskSysDictEnum.risk_level, this.getAfterRiskLevel());
    }
    public SysDictItem getRiskLevelLabelValue() {
        return DictResolver.getItemByValue(RiskSysDictEnum.risk_level, Optional.ofNullable(this.getRiskLevel()).map(String::valueOf).orElse(null));
    }
    public SysDictItem getAfterRiskLevelLabelValue() {
        return DictResolver.getItemByValue(RiskSysDictEnum.risk_level, Optional.ofNullable(this.getAfterRiskLevel()).map(String::valueOf).orElse(null));
    }
}
